<div class="row"><div class="span10 offset1">	<?php echo flash_message();?>

<?php 

if (isset($posts) ) { 
if(count($posts)>0)
{	
	
	?>
	
<header>

<h3 >Posts Managament</h3>	

<?php 
echo form_open('post/index',array("class"=>"well form-search"));   
echo form_input('search',set_value('search','search'));
echo form_submit('submit',set_value('submit','search'));
echo form_fieldset_close();  
?>

</header>



<?php

	$tmpl = array (
                    'table_open'=> '<table class="tablesorter table table-bordered" cellspacing="0">',
              );

$this->table->set_template($tmpl); 
	$datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
	
	foreach ($posts as $post) {
		
				$links = '<div class="btn-group"><a class="btn btn-primary" href="#"><i class="icon-align-justify icon-white"></i> Post</a><a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a><ul class="dropdown-menu">';		$links .= '<li>';  		$links .= anchor('post/edit/' . $post->getId(), '<i class="icon-pencil"></i> Edit');		$links .='</li>';		$links .= '<li>';  		$links .= anchor('post/delete/' . $post->getId(), '<i class="icon-trash"></i> Delete',array('onclick'=>"return confirm('Are you sure want to delete this post?')"));		$links .='</li>';					$links .= "<ul></div>";											$this -> table -> set_heading('Post title', 'Clear title', 'Author', 'Actions');
		$this -> table -> add_row($post->getTitle(), $post->getTitleClean(),  $post->getAuthor()->getFullName(), $links);
	}

	echo $this -> table -> generate();
	
	if (PAGINATION_ENABLED && isset($this -> pagination) )
	{    
		echo '<div class="pagination_container">' . $this -> pagination -> create_links() . '</div>';
	}
?>
<div class="other_actions">
	<?php echo anchor('post/create','Add Post');?>
</div>	
<?php 
}}
 else{
 	?>
	 <p  style="padding-left: 10px">no result found.... <?php echo anchor('post/create','Write a Post');?></p> 
<?php
 }
 ?>
</div>
</div>